﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ManageStudentNew.aspx.cs" Inherits="Teacher_CORRECTASKANSWER" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script src="../layui/layui.js"></script>
    <script src="../JS/jquery-3.3.1.min.js"></script>
    <link href="../layui/css/layui.css" rel="stylesheet" />
    <script type="text/html" id="tableBarTool">
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
    </script>


</head>
<body>
    <script>

        var TableJson;
        layui.use(['table', 'layer'], function () {
            var table = layui.table;
            var layer = layui.layer;


            //第一个实例
            table.render({
                elem: '#UserList'
                , url: '/handler/EMSsystem.ashx?Action=UserList&Method=GetTable' //数据接口
                , page: true //开启分页
                , cols: [[ //表头
                    { type: 'radio', title: '选择' }
                    , { field: 'ID', title: 'ID', hide: true }
                    , { field: 'USER_NAME', title: '姓名', width: 200 }
                    , { field: 'LOGIN_NAME', title: '登录名', width: 200 }
                    , { field: 'LOGIN_PASS', title: '登录密码', width: 200 }
                    , { field: 'COMPANY', title: '公司', width: 200 }
                    , { field: 'DEPARTMENT', title: '部门', width: 200 }
                    , { field: 'PAPERID', title: '试卷ID', width: 400 }
                    , { fixed: 'right', title: '操作', align: 'center', toolbar: '#tableBarTool' }
                ]]
            });

            table.on('tool(UserList)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                var data = obj.data //获得当前行数据
                    , layEvent = obj.event; //获得 lay-event 对应的值
                if (layEvent === 'edit') {
                    TableJson = JSON.stringify(data);
                    layer.open({
                        title: '编辑'
                        , type: 2
                        , area: ['1000px', '700px']
                        , content: 'EditStudent.aspx'
                        , end: function () {
                            table.reload('UserList');
                        }

                    });

                } else if (layEvent === 'delete') {
                    layer.confirm('确认删除该客户信息?', { icon: 3, title: '删除' }, function (index) {
                        $.ajax({
                            type: "post",
                            url: '/handler/EMSsystem.ashx?Action=UserList&Method=Delete', //数据接口
                            data: { "ID": data.ID },
                            success: function (obj) {
                                if (obj) {
                                    var back = eval('(' + obj + ')');
                                    var msg = back.msg;
                                    layer.msg(msg);
                                    table.reload('UserList');
                                }
                            }
                        })

                        layer.close(index);
                    });
                }
            });


            $("#btnSearchName").click(function () {
                table.reload('UserList', {
                    where: {
                        Name: $("#SearchName").val()
                    }
                    , page: {
                        curr: 1
                    }
                });
            });


        });
    </script>

    <div class="demoTable">
        搜索姓名：
    <div class="layui-inline">
        <input class="layui-input" name="SearchName" id="SearchName" autocomplete="off" />
    </div>
        <button class="layui-btn" id="btnSearchName" data-type="reload">搜索</button>
    </div>
    <table id="UserList" lay-filter="UserList"></table>
</body>
</html>
